package Thread;

import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

//使用java标准库中提供的线程池类
//获取线程池中的线程的名字；
public class Demo34 {
    public static void main(String[] args){
        //ExecutorService threadPoll= Executors.newFixedThreadPool(4);
          ExecutorService threadPoll=Executors.newCachedThreadPool();
          for(int i=0;i<20;i++){
              int id=i;
              threadPoll.submit(()->{
                  System.out.println("hello " +"{"+id+"}" +Thread.currentThread().getName());
              });
          }
    }
}
